#include<bits/stdc++.h>
using namespace std;
int T,n,m,L,V,p[100009],ans=0;
struct node{
    int d,v,a;
}dva[100009];
inline int sv(int v,int a,int s){
    return sqrt(v*v+2*a*s);
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        ans=0;
        bool flag=0;
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&dva[i].d,&dva[i].v,&dva[i].a);
            if(dva[i].a!=0) flag=1;
        }
        for(int i=1;i<=m;i++)
            scanf("%d",&p[i]);
        if(!flag){
            for(int i=1;i<=n;i++){
                if(dva[i].v>V&&dva[i].d<=p[m]) ans++;
            }if(ans!=0)printf("%d %d\n",ans,m-1);
            else printf("0 %d\n",m);
        }else{
            for(int i=1;i<=n;i++){
                if(sv(dva[i].v,dva[i].a,L-dva[i].d)>V&&dva[i].d<=p[m]) ans++;
            }if(ans!=0)printf("%d %d\n",ans,m-1);
            else printf("0 %d\n",m);
        }
    }return 0;
}
